package com.changan.stumgr.mapper;

import com.changan.stumgr.pojo.Student;
import org.apache.ibatis.annotations.*;
import org.mybatis.spring.annotation.MapperScan;

import java.util.List;


public interface StudentMapper {

  /*  @Select("select * from student where name like CONCAT('%', #{searchName},'%')")*/
    List<Student> selAllStudent(@Param("searchName") String searchName);

    @Select("select * from student  where id = #{id}")
    Student findByIdStudent(Integer id);

    @Insert("INSERT INTO `studentdb`.`student`(`id`, `name`, `sex`, `gradeId`) VALUES (null, #{name}, #{sex}, #{gradeId})")
    int addStudent(Student student);

    @Delete("delete from student where id = #{id}")
    int delStudent(Integer id);

    @Update("UPDATE `studentdb`.`student` SET `name` = #{name}, `sex` = #{sex}, `gradeId` = #{gradeId} WHERE `id` = #{id}")
    int updateStudent(Student student);

    @Select("select * from student where id = #{id}")
    Student findStudentById(Integer id);
}
